%funkcja mnozaca wszystkie elementy macierzy, wynik w postaci (coef * 10^sig)
function [coef, sig] = myprod(matrix)

[M, N] = size(matrix);

sig = zeros(M, N);
coef = matrix;

indx = 0;
while ~isempty(indx)
    indx = find(coef < 1 & coef > 0);
    coef(indx) = coef(indx) .* 10;
    sig(indx) = sig(indx) - 1;
    
    indx = find(coef < 1 & coef > 0);
end

indx = 0;
while ~isempty(indx)
    indx = find(coef > 10);
    coef(indx) = coef(indx) ./ 10;
    sig(indx) = sig(indx) + 1;
    
    indx = find(coef > 10);
end

coef = prod(coef, 1);
sig = sum(sig, 1);

indx = 0;
while ~isempty(indx)
    indx = find(coef < 1 & coef > 0);
    coef(indx) = coef(indx) .* 10;
    sig(indx) = sig(indx) - 1;
    
    indx = find(coef < 1 & coef > 0);
end

indx = 0;
while ~isempty(indx)
    indx = find(coef > 10);
    coef(indx) = coef(indx) ./ 10;
    sig(indx) = sig(indx) + 1;
    
    indx = find(coef > 10);
end

coef = prod(coef);
sig = sum(sig);

indx = 0;
while ~isempty(indx)
    indx = find(coef < 1 & coef > 0);
    coef(indx) = coef(indx) .* 10;
    sig(indx) = sig(indx) - 1;
    
    indx = find(coef < 1 & coef > 0);
end

indx = 0;
while ~isempty(indx)
    indx = find(coef > 10);
    coef(indx) = coef(indx) ./ 10;
    sig(indx) = sig(indx) + 1;
    
    indx = find(coef > 10);
end